package com.atguigu.cdc.handler;

import com.atguigu.cdc.model.CDCEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import top.javatool.canal.client.annotation.CanalTable;
import top.javatool.canal.client.handler.EntryHandler;
@Component
@CanalTable("user_info") //监听变更表
public class UserCdcHandler implements EntryHandler<CDCEntity> {
    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public void update(CDCEntity before, CDCEntity after) {
        redisTemplate.delete("userInfoVo"+after.getId());
    }

    @Override
    public void delete(CDCEntity cdcEntity) {
        redisTemplate.delete("userInfoVo"+cdcEntity.getId());
    }
}
